<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
//CHECK UPLOAD
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'user.session.class.php');
$usObj = new UserSessionBase();
$check = $usObj->checkAdmin($request_link_subclass);
if( $check == false ) {
	echo 'error';
	exit();
}

//
$MAXIMUM_FILESIZE = 300 * 1024 * 1024; // 300,000,000 Byte
$MAXIMUM_POSTSIZE = 300 * 1024 * 1024; // 300,000,000 Byte

//
if( isset($_FILES['Filedata']) && $_FILES['Filedata']['size'] <= $MAXIMUM_FILESIZE ) {
	include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.upload.class.php');
	
	//
	$uploadObj = new CoreUpload('Filedata');
	$uploadObj->setDestination(CONFIG_PATH . CONFIG_DIR_UPLOADS);
	$uploadObj->setRandFilename(false);
	if( $uploadObj->parse() && $uploadObj->save() ) {
		$upload_filename = $uploadObj->save_filename;
		
		$result = $upload_filename;
	} else {
		$result = 'fail';
	}
} else {
	$result = 'fail';
}
echo $result;
exit();
//
?>